package cn.whale.pay.service.impl;

import cn.whale.pay.domain.PayFlow;
import cn.whale.pay.mapper.PayFlowMapper;
import cn.whale.pay.service.IPayFlowService;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author whale.chen
 * @since 2020-12-12
 */
@Service
public class PayFlowServiceImpl extends ServiceImpl<PayFlowMapper, PayFlow> implements IPayFlowService {

    @Override
    public PayFlow selectByPayNo(String tradeNo) {
        return baseMapper.selectByPayNo(tradeNo) ;
    }

    @Override
    public boolean updateById(PayFlow entity) {
        EntityWrapper<PayFlow> objectEntityWrapper = new EntityWrapper<>();
        //乐观锁
        objectEntityWrapper.eq("version",entity.getVersion());
        return baseMapper.update(entity,objectEntityWrapper) > 0;
    }
}
